﻿using CefSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 哇哦软件开发
{
    internal class CustomKeyboardHandler : IKeyboardHandler
    {
        public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type,
                          int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
        {
            if (type == KeyType.KeyUp && windowsKeyCode == (int)Keys.F5)
            {
                browserControl.Reload(modifiers == CefEventFlags.ControlDown);
                return true;
            }
            // 新增F12调试逻辑
            if (type == KeyType.KeyUp && windowsKeyCode == (int)Keys.F12)
            {
                browserControl.ShowDevTools();
                return true;
            }

            return false;
        }
        public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool handled)
        {
            handled = false;
            return false;
        }
    }
}
